The present invention relates in general to generation of image data in computer systems and in particular to a desktop compositor using copy-on-write semantics.
Computer display devices typically display images by coloring each of a number of independent pixels (picture elements) that cover the display area. The computer system determines a color value for each pixel using various well-known graphics processing techniques. Once color values are generated, pixel data representing the color values is written to a “frame buffer,” an area of memory with sufficient capacity to store color data for each pixel of the display device. To display an image, scanout control logic reads the pixel values sequentially from the frame buffer and converts them to analog signals that produce the desired pixel colors on the display device. Scanout is generally performed at a constant frame rate, e.g., 80 Hz.
The demand for access to the frame buffer memory can be quite large. For instance, scanout at 80 Hz for a 1024×768 pixel display with 32-bit color requires the capacity to read 2 Gbits per second. At the same time, data for the next frame is also being written to the frame buffer, often at high rates. Thus, memory bandwidth is generally a scarce resource in image generation systems.
To improve memory access times and to prevent undesirable visual artifacts that can result if data in the frame buffer is updated during scanout of a frame, many image generation systems provide a double-buffered frame buffer. In these systems, the frame buffer includes two memory spaces, each of which has sufficient capacity to store pixel data for a complete display frame. At a given time, one memory space is designated as the “back” buffer while the other is designated as the “front” buffer. Applications write pixel data to the back buffer while the front buffer is scanned out for display. The two memory spaces are generally designed to be accessed in parallel, to reduce conflicts between updating and scanout operations. At the end of each scanout frame, the buffers are swapped, i.e., the memory space designated as the front buffer becomes the back buffer and vice versa. The next frame is written to the new back buffer while the new front buffer is scanned out.
To avoid writing an entire frame to the back buffer, some existing systems also copy the content of the back buffer to the front buffer at the time of swapping, so that the back buffer can be updated during the next frame, rather than being completely rewritten. This procedure can reduce demand for write access during the frame interval, but the peak demand for memory bandwidth can be quite high due to the need to copy an entire frame of pixel data at the end of each frame.
To increase control over the appearance of the desktop and to provide better management of memory bandwidth, an image generation system with a “desktop compositor” has been proposed. In a desktop compositor system, each application writes its pixel data to a dedicated drawing memory area that is not scanned out. A desktop compositor then selects one or more of the drawing memory areas to provide the pixel data to be displayed for a given pixel (or group of pixels, referred to as a tile) and writes appropriate pixel data to the desktop frame buffer.
FIG. 1 illustrates the pixel buffers and data transfers required for one implementation of a desktop compositor. Each application 102 (104) has a pair of drawing buffers 106, 108 (110, 112). Application 102 (104) writes pixel data to its “back” drawing buffer 106 (110). In parallel, a desktop compositor 114 reads pixel data from the front drawing buffers 108 (112) of one or more of the applications, performs any desired manipulations and writes or copies pixel data to a “back” desktop (frame) buffer 116. In parallel with operation of the desktop compositor, scanout control logic 118 scans out a “front” desktop buffer 120 for displaying on a display device (not shown). Periodically (e.g., at the end of each frame), the back and front buffers of each pair are swapped—i.e., the buffer that was used as the back buffer becomes the front buffer and vice versa. After swapping, the new front desktop buffer 116 is typically copied to the new back desktop buffer 120 so that the next frame can be generated by incremental updating of the pixel data. The new front drawing buffer 106 for an application can also be copied to the corresponding new back drawing buffer 108; this is generally done where the application performs incremental updating of its drawing buffer. For applications that redraw their entire drawing buffers during each frame, copying data between the application's two drawing buffers is unnecessary.
Such systems generally require pixel data to be transferred several times. For instance, data may be written to a back drawing buffer, copied to a front drawing buffer, read by the desktop compositor, written to the back desktop buffer, and copied from the back desktop buffer to the front desktop buffer. These transfers occur regardless of whether the data has changed or not. The memory bandwidth required to perform these transfers can be considerable, resulting in degradation of system performance.
It is therefore desirable to provide a system that reduces the need for transferring pixel data from one buffer to another.